package varvelworld.algorithm.DuplicationFinding;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;


public class JDKSort implements IDuplicationFinding {

    @Override
    public List<Long> execute(long[] a) {
        List<Long> result = new ArrayList<Long>();
        Arrays.sort(a);
        int s = 1;
        for(int i = 1; i < a.length; i++){
            if(a[i - 1] == a[i]){
                s++;
            }else{
                s = 1;
            }
            if(s == 2){
                result.add(a[i]);
            }
        }
        return result;
    }

}
